<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <title>Báo cáo Tổng hợp cuộc gọi</title>
        <script>
            function confirmComplete() {
                var answer = confirm("Bạn có chắc chắn muốn xóa bản ghi này?");
                if (answer == true)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        </script>        
    </h:head>
    <h:body> 
        <link type="text/css" rel="stylesheet" href="../css/main.css" />        
        <style type="text/css">
            .ui-widget{font-size:95% !important;}
            .ui-layout-unit-content{background-color: #E5E5E5;border-width: 0px}      
            .ui-widget{border-width: 0px;color: red}
        </style>
        <div align="center" id="bodyForm" >            
            <div style="width: 100%;">
                <p:layoutUnit id="top" position="north" size="auto">
                    <ui:insert name="menu">
                        <ui:include src="../../templates/menu.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit id="center" position="center" size="400">
                    <h1 class="headerbar">Báo cáo Tổng hợp cuộc gọi</h1>
                    <h:form id="form">
                        <p:dialog modal="true" widgetVar="statusDialog" header="Đang tìm kiếm.."   
                                  draggable="false" closable="false">  
                            <p:graphicImage value="../../images/ajax-loader.gif" />  
                        </p:dialog>
                        <br></br>
                        <p:growl/> 
                        <h:panelGrid columns="4">
                            <h:outputText value="Từ ngày: "/> <p:calendar pattern="dd-MM-yyyy" showOn="button" value="#{sUM_FS_CDRController.tuNgay}" required="true" requiredMessage="Không được để trống từ ngày"/>
                            <h:outputText value="Đến ngày: "/> <p:calendar pattern="dd-MM-yyyy" showOn="button" value="#{sUM_FS_CDRController.denNgay}" required="true" requiredMessage="Không được để trống đến ngày"/>
                            <h:outputText value="Extension: "/> 
                            <p:selectOneMenu style="float: left;width: 176px;" value="#{sUM_FS_CDRController.extension}">                                                              
                                <f:selectItems value="#{sUM_FS_CDRController.listIE}" var="ie" itemLabel="#{ie.extension}" itemValue="#{ie.extension}" />                                         
                            </p:selectOneMenu>                                                 
                            <h:outputText value=""/>
                            <p:selectManyCheckbox value="#{sUM_FS_CDRController.chitiet}">  
                            <f:selectItem itemLabel="Chi tiết theo ngày" itemValue="dd" />  
                            </p:selectManyCheckbox>                                                                             
                        </h:panelGrid>                            
                        <p:commandButton value="Thống kê" action="#{sUM_FS_CDRController.thongke()}" update=":form" onclick="statusDialog.show();" oncomplete="statusDialog.hide();"/>
                        <p:dataTable value="#{sUM_FS_CDRController.lazyModel}" var="l" 
                                     paginator="true" rows="20" paginatorPosition="bottom" rowsPerPageTemplate="20,25,30"
                                     lazy="true">
                            <p:column headerText="Thời gian">
                                <h:outputText value="#{l.sum_date}" rendered="#{sUM_FS_CDRController.chitiet.size() > 0}" style="float: right"/>
                                <h:outputText value="#{sUM_FS_CDRController.time}" rendered="#{sUM_FS_CDRController.chitiet.size() eq 0}" style="float: right"/>
                            </p:column>
                            <p:column headerText="Extension">
                                <h:outputText value="#{l.extension}" style="float: right;width: 150px"/>
                            </p:column>
                            <p:column headerText="Số cuộc lỡ" style="width: 150px">
                                <h:outputText value="#{l.missed_calls}" style="float: right"/>
                            </p:column>
                            <p:column headerText="Số cuộc nghe" style="width: 150px">
                                <h:outputText value="#{l.answered_calls}" style="float: right"/>
                            </p:column>
                            <p:column headerText="Số cuộc từ chối" style="width: 150px">
                                <h:outputText value="#{l.rejected_calls}" style="float: right"/>
                            </p:column>
                            <p:column headerText="Thời lượng nghe" style="width: 150px">            
                                <h:outputText value="#{sUM_FS_CDRController.makeTime(l.total_answer_duration)}" style="float: right"/>
                            </p:column>
                            <p:column headerText="Thời lượng nghe TB" style="width: 150px">
                                <h:outputText value="#{sUM_FS_CDRController.makeTime(l.average_answer_duration)}" style="float: right"/>
                            </p:column>
                            <p:column headerText="Thời lượng chờ TB" style="width: 150px">
                                <h:outputText value="#{sUM_FS_CDRController.makeTime(l.average_response_duration)}" style="float: right"/>
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </p:layoutUnit>
                <p:layoutUnit id="bottom" position="bottom" size="60">
                    <ui:insert name="footer">
                        <ui:include src="../../templates/footer.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>
            </div>
        </div>
    </h:body>
</html>

